#include<stdio.h>
#include<signal.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
void handler(int signo)
{
    printf("got a singal！ signo: %d\n", signo);
    signal(signo, handler);
}
int main()
{
  while(1)
  {
    if(fork()==0)
    {
      printf("i am child %d\n",getpid());
      sleep(1);
      int a=1/0;
    }
    int status=0;
    waitpid(-1,&status,0);
    printf("exit code:%d,coredump:%d,signal:%d\n", (status>>8)&0xff, (status>>7)&1 ,status&0x7f);
    signal(2,handler);
  }
  return 0;
}
